﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.Plumbing
{
	public partial class WaterTankCalculate : System.Windows.Forms.Form
	{
		public WaterTankCalculate(Document Doc)
		{
			this.InitializeComponent();
			this.doc = Doc;
			//base.Icon = Resource.YArchitechIcon;
			base.CenterToScreen();
		}

		private void WaterTankCalculate_Load(object sender, EventArgs e)
		{
			this.rbsh.Checked = true;
			this.rbzd.Checked = true;
			this.radioButton1.Checked = true;
			this.panel1.Parent = this.groupBox4;
			this.panel2.Parent = this.groupBox4;
			this.panel3.Parent = this.groupBox4;
			this.panel4.Parent = this.groupBox4;
			this.cbjzdj.Items.Add("一类建筑最小36m3");
			this.cbjzdj.Items.Add("多层公共、二类高层、一类居住建筑最小18m3");
			this.cbjzdj.Items.Add("二类高层最小12m3");
			this.cbjzdj.Items.Add("多层住宅最小6m3");
			this.cbjzdj.SelectedIndex = 0;
			this.initParameterSetting();
			this.InitDataGridViewColumn();
			this.GetAllWaterTankInfo();
		}

		private void rbzd_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbzd.Checked)
			{
				if (this.radioButton1.Checked)
				{
					this.panel1.Visible = true;
					this.panel2.Visible = false;
					this.panel3.Visible = false;
					this.panel4.Visible = false;
				}
				if (this.radioButton2.Checked)
				{
					this.panel1.Visible = false;
					this.panel2.Visible = true;
					this.panel3.Visible = false;
					this.panel4.Visible = false;
				}
			}
			this.Refresh();
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void rbrg_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbrg.Checked)
			{
				this.panel1.Visible = false;
				this.panel2.Visible = false;
				this.panel3.Visible = true;
				this.panel4.Visible = false;
				this.panel3.BringToFront();
			}
			this.Refresh();
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void rbds_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbds.Checked)
			{
				this.panel4.BringToFront();
				this.panel1.Visible = false;
				this.panel2.Visible = false;
				this.panel3.Visible = false;
				this.panel4.Visible = true;
			}
			this.Refresh();
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void radioButton1_CheckedChanged(object sender, EventArgs e)
		{
			if (this.radioButton1.Checked)
			{
				this.panel1.Visible = true;
				this.panel2.Visible = false;
				this.panel3.Visible = false;
				this.panel4.Visible = false;
			}
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void radioButton2_CheckedChanged(object sender, EventArgs e)
		{
			if (this.radioButton2.Checked)
			{
				this.panel1.Visible = false;
				this.panel2.Visible = true;
				this.panel3.Visible = false;
				this.panel4.Visible = false;
			}
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void rbsh_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbsh.Checked)
			{
				this.groupBox2.Enabled = true;
				this.groupBox3.Enabled = false;
				this.groupBox4.Enabled = true;
			}
			this.shysrj.Text = "";
			this.zrj.Text = "";
		}

		private void rbxf_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbxf.Checked)
			{
				this.groupBox2.Enabled = false;
				this.groupBox3.Enabled = true;
				this.groupBox4.Enabled = false;
			}
			this.shysrj.Text = "";
			this.xfysrj.Text = "";
			this.zrj.Text = "";
		}

		private void rbhy_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbhy.Checked)
			{
				this.groupBox2.Enabled = true;
				this.groupBox3.Enabled = true;
				this.groupBox4.Enabled = true;
			}
			this.shysrj.Text = "";
			this.xfysrj.Text = "";
			this.zrj.Text = "";
		}

		public double CalculateShuiBengZiDongJS(int Nmax, double Qb)
		{
			return 1.25 * Qb / (double)(4 * Nmax);
		}

		public double CalculateShuiBengZiDongGS(double Qb, double Q, double T, double Tb)
		{
			return (Q - Qb) * T + Qb * Tb;
		}

		public double CalculateShuiBengRenGong(double Qd, double Qm, double Tb, int n)
		{
			return Qd / (double)n - Tb * Qm;
		}

		public double CalculateDanSheShuiXiang(double Qm, double T)
		{
			return Qm * T;
		}

		public double CalculateXF(double Q, double T)
		{
			return Q / 1000.0 * 60.0 * T;
		}

		public double SheWeiLieFugongshi(double l, double q, double D)
		{
			double result = 0.0;
			double num = q / (Math.PI * Math.Pow(D / 2.0, 2.0));
			if (num >= 1.2)
			{
				result = 0.00107 * Math.Pow(num, 2.0) * l / Math.Pow(D, 13.0);
			}
			else if (num < 1.2)
			{
				result = 0.000912 * Math.Pow(num, 2.0) * l * Math.Pow(1.0 + 0.867 / num, 0.3) / Math.Pow(D, 1.3);
			}
			return result;
		}

		public double HaiCengWeiLiangongshi(double l, double q, double D, double Cw)
		{
			return 10.67 * Math.Pow(q, 1.852) * l / (Math.Pow(Cw, 1.852) * Math.Pow(D, 4.87));
		}

		public double KeErBoLuoKeHuaiTegongshi(double l, double q, double D, double x, double e)
		{
			double num = q / (Math.PI * Math.Pow(D / 2.0, 2.0));
			double num2 = 0.25 * D;
			double x2 = num * D / x;
			double x3 = -17.7 * Math.Log10(e / (3.7 * D) + 4.462 / Math.Pow(x2, 0.875));
			return Math.Pow(num, 2.0) * l / (Math.Pow(x3, 2.0) * num2);
		}

		public double BaFuLuoFuSiJigongshi(double l, double q, double D, double nb)
		{
			double x = q / (Math.PI * Math.Pow(D / 2.0, 2.0));
			double num = 0.25 * D;
			double num2 = 2.5 * Math.Sqrt(nb) - 0.13 - 0.73 * Math.Sqrt(num) * (Math.Sqrt(nb) - 0.1);
			return Math.Pow(nb, 2.0) * Math.Pow(x, 2.0) * l / Math.Pow(num, 2.0 * num2 + 1.0);
		}

		public double Mannninggongshi(double l, double q, double D, double n)
		{
			return 10.29 * Math.Pow(n, 2.0) * Math.Pow(q, 2.0) * l / Math.Pow(D, 5.333);
		}

		private void btnJS_Click(object sender, EventArgs e)
		{
			double num = 0.0;
			double num2 = 0.0;
			if (this.rbxf.Checked || this.rbhy.Checked)
			{
				if (!(this.xfshuiliang.Text.ToString() != "") || !(this.xftime.Text.ToString() != ""))
				{
					YJKMessageBox.Information("参数不能为空");
					return;
				}
				double num3 = this.CalculateXF(double.Parse(this.xfshuiliang.Text.ToString()), double.Parse(this.xftime.Text.ToString()));
				if (this.cbjzdj.SelectedIndex == 0)
				{
					num2 = ((num3 > 36.0) ? num3 : 36.0);
				}
				if (this.cbjzdj.SelectedIndex == 1)
				{
					num2 = ((num3 > 18.0) ? num3 : 18.0);
				}
				else if (this.cbjzdj.SelectedIndex == 2)
				{
					num2 = ((num3 > 12.0) ? num3 : 12.0);
				}
				else if (this.cbjzdj.SelectedIndex == 3)
				{
					num2 = ((num3 > 6.0) ? num3 : 6.0);
				}
				this.xfysrj.Text = num2.ToString();
			}
			if (this.rbsh.Checked || this.rbhy.Checked)
			{
				if (this.rbzd.Checked)
				{
					if (this.radioButton1.Checked)
					{
						if (!(this.zdNmax.Text.ToString() != "") || !(this.zdQb.Text.ToString() != ""))
						{
							YJKMessageBox.Information("参数不能为空");
							return;
						}
						num = this.CalculateShuiBengZiDongJS(int.Parse(this.zdNmax.Text.ToString()), double.Parse(this.zdQb.Text.ToString()));
					}
					else if (this.radioButton2.Checked)
					{
						if (!(this.gsQb.Text.ToString() != "") || !(this.gsQ.Text.ToString() != "") || !(this.gsT.Text.ToString() != "") || !(this.gsTb.Text.ToString() != ""))
						{
							YJKMessageBox.Information("参数不能为空");
							return;
						}
						num = this.CalculateShuiBengZiDongGS(double.Parse(this.gsQb.Text.ToString()), double.Parse(this.gsQ.Text.ToString()), double.Parse(this.gsT.Text.ToString()), double.Parse(this.gsTb.Text.ToString()));
					}
				}
				else if (this.rbrg.Checked)
				{
					if (!(this.rbQb.Text.ToString() != "") || !(this.rbQm.Text.ToString() != "") || !(this.rbTb.Text.ToString() != "") || !(this.rbn.Text.ToString() != ""))
					{
						YJKMessageBox.Information("参数不能为空");
						return;
					}
					num = this.CalculateShuiBengRenGong(double.Parse(this.rbQb.Text.ToString()), double.Parse(this.rbQm.Text.ToString()), double.Parse(this.rbTb.Text.ToString()), int.Parse(this.rbn.Text.ToString()));
				}
				else if (this.rbds.Checked)
				{
					if (!(this.dzQm.Text.ToString() != "") || !(this.dzT.Text.ToString() != ""))
					{
						YJKMessageBox.Information("参数不能为空");
						return;
					}
					num = this.CalculateDanSheShuiXiang(double.Parse(this.dzQm.Text.ToString()), double.Parse(this.dzT.Text.ToString()));
				}
				num = Math.Round(num, 2, MidpointRounding.ToEven);
				this.shysrj.Text = num.ToString();
			}
			double num4 = num + num2;
			this.zrj.Text = num4.ToString();
			this.UserSettingWrite();
			this.rdFilter.Enabled = true;
			this.rdAllTank.Enabled = true;
			this.rdFilter.Checked = true;
		}

		private void SaveFileDialog()
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "文本文件|*.txt";
			saveFileDialog.FilterIndex = 1;
			saveFileDialog.RestoreDirectory = true;
			if (saveFileDialog.ShowDialog() == DialogResult.OK)
			{
				string text = saveFileDialog.FileName.ToString();
				string str = text.Substring(text.LastIndexOf("\\") + 1);
				text.Substring(0, text.LastIndexOf("\\"));
                ////DateTime.Now.ToString("yyyyMMdd") + str;
				saveFileDialog.FileName.Insert(1, "dameng");
				this.WriteTXT(text);
				if (MessageBox.Show("是否现在查看？", "盈建科提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
				{
					Process.Start(text);
				}
			}
		}

		private void button4_Click(object sender, EventArgs e)
		{
			this.SaveFileDialog();
		}

		private void WriteTXT(string path)
		{
			FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(" ");
			streamWriter.WriteLine("                         水箱计算");
			streamWriter.WriteLine(" ");
			streamWriter.WriteLine("水箱容积计算：");
			if (this.rbxf.Checked)
			{
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine(" 水箱只用于消防用水");
				streamWriter.WriteLine(" ");
				this.WriteXFYS(streamWriter);
				streamWriter.WriteLine("");
			}
			if (this.rbsh.Checked)
			{
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine(" 水箱只用于生活用水");
				streamWriter.WriteLine(" ");
				this.WriteSHYS(streamWriter);
				streamWriter.WriteLine("");
			}
			if (this.rbhy.Checked)
			{
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine("  生活用水容积计算：");
				streamWriter.WriteLine(" ");
				this.WriteSHYS(streamWriter);
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine("  消防用水容积计算");
				streamWriter.WriteLine(" ");
				this.WriteXFYS(streamWriter);
				streamWriter.WriteLine(" ");
				streamWriter.WriteLine("  水箱容积= 生活用水容积Vt + 消防用水容积V");
				streamWriter.WriteLine(" ");
			}
			streamWriter.WriteLine("  计算结果：");
			streamWriter.WriteLine("      水箱容积=" + this.zrj.Text.ToString() + "m3");
			streamWriter.Close();
			fileStream.Close();
		}

		public void WriteXFYS(StreamWriter sw)
		{
			sw.WriteLine("  已知条件：");
			sw.WriteLine("      Q:消防水量(L/S)： " + this.xfshuiliang.Text.ToString());
			sw.WriteLine("      T时间(min)： " + this.xftime.Text.ToString());
			sw.WriteLine("      建筑等级: " + this.cbjzdj.SelectedItem.ToString());
			sw.WriteLine(" ");
			sw.WriteLine("  计算公式");
			sw.WriteLine("      消防用水容积:V=(Q / 1000) * 60 * T");
			sw.WriteLine("");
			sw.WriteLine("  计算过程：");
			sw.WriteLine("      消防用水容积:V=" + this.xfshuiliang.Text.ToString() + "/1000 * 60 *" + this.xftime.Text.ToString());
		}

		public void WriteSHYS(StreamWriter sw)
		{
			if (this.rbzd.Checked)
			{
				sw.WriteLine("  运行方式：水泵自动");
				if (this.radioButton1.Checked)
				{
					sw.WriteLine(" ");
					sw.WriteLine("  已知条件：");
					sw.WriteLine("      小时最大启动次数Nmax: " + this.zdNmax.Text.ToString());
					sw.WriteLine("      水泵的出水量Qb(m3/h): " + this.zdQb.Text.ToString());
					sw.WriteLine(" ");
					sw.WriteLine("  计算公式");
					sw.WriteLine("       生活用水容积:Vt=1.25*Qb/(4*Nmax)");
					sw.WriteLine("");
					sw.WriteLine("  计算过程：");
					sw.WriteLine(string.Concat(new object[]
					{
						"      生活用水容积:Vt =",
						1.25,
						"*",
						this.zdQb.Text.ToString(),
						"/(",
						4,
						"*",
						this.zdNmax.Text.ToString(),
						")"
					}));
					return;
				}
				if (this.radioButton2.Checked)
				{
					sw.WriteLine("  已知条件：");
					sw.WriteLine("      水泵的出水量Qb(m3/h):" + this.gsQb.Text.ToString());
					sw.WriteLine("      设计秒流量Q(m3/h):" + this.gsQ.Text.ToString());
					sw.WriteLine("      秒流量持续时间T(0.5h):" + this.gsT.Text.ToString());
					sw.WriteLine("      最短运行时间Tb(0.25h):" + this.gsTb.Text.ToString());
					sw.WriteLine(" ");
					sw.WriteLine("  计算公式");
					sw.WriteLine("      生活用水容积:Vt=(Q-Qb)T+QbTb");
					sw.WriteLine("");
					sw.WriteLine("  计算过程：");
					sw.WriteLine(string.Concat(new string[]
					{
						"      生活用水容积:Vt =(",
						this.gsQ.Text.ToString(),
						"-",
						this.gsQb.Text.ToString(),
						")*",
						this.gsT.Text.ToString(),
						"+",
						this.gsQb.Text.ToString(),
						"*",
						this.gsTb.Text.ToString()
					}));
					return;
				}
			}
			else
			{
				if (this.rbrg.Checked)
				{
					sw.WriteLine("  运行方式：水泵人工");
					sw.WriteLine("  已知条件：");
					sw.WriteLine("      最高日用水量Qd(m3)：" + this.rbQb.Text.ToString());
					sw.WriteLine("      平均每小时用水量Qm(m3)：" + this.rbQm.Text.ToString());
					sw.WriteLine("      启动一次运行时间Tb(h)：" + this.rbTb.Text.ToString());
					sw.WriteLine("      水泵每天启动次数n：" + this.rbn.Text.ToString());
					sw.WriteLine(" ");
					sw.WriteLine("  计算公式");
					sw.WriteLine("      生活用水容积:Vt=Qd/n-Tb*Qm");
					sw.WriteLine("");
					sw.WriteLine("  计算过程：");
					sw.WriteLine(string.Concat(new string[]
					{
						"      生活用水容积:Vt =",
						this.rbQb.Text.ToString(),
						"/",
						this.rbn.Text.ToString(),
						"-",
						this.rbTb.Text.ToString(),
						"*",
						this.rbQm.Text.ToString()
					}));
					return;
				}
				if (this.rbds.Checked)
				{
					sw.WriteLine("  运行方式：单设水箱");
					sw.WriteLine("  已知条件：");
					sw.WriteLine("      平均每小时用水量Qm(m3)：" + this.dzQm.Text.ToString());
					sw.WriteLine("      最大连续时间T(h)：" + this.dzT.Text.ToString());
					sw.WriteLine(" ");
					sw.WriteLine("  计算公式");
					sw.WriteLine("      生活用水容积:Vt=Qm*T");
					sw.WriteLine("");
					sw.WriteLine("  计算过程：");
					sw.WriteLine("      生活用水容积:Vt =" + this.dzQm.Text.ToString() + "*" + this.dzT.Text.ToString());
				}
			}
		}

		private void button5_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void initParameterSetting()
		{
			UserSetting userSetting = new UserSetting();
			string value = userSetting.GetValue("WaterTankCalculate", "yongtu");
			if (!(value == "消防"))
			{
				if (!(value == "生活"))
				{
					if (value == "合用")
					{
						this.rbhy.Checked = true;
					}
				}
				else
				{
					this.rbsh.Checked = true;
				}
			}
			else
			{
				this.rbxf.Checked = true;
			}
			string value2 = userSetting.GetValue("WaterTankCalculate", "fangshi");
			if (!(value2 == "水泵自动"))
			{
				if (!(value2 == "水泵人工"))
				{
					if (value2 == "单设水箱")
					{
						this.rbds.Checked = true;
					}
				}
				else
				{
					this.rbrg.Checked = true;
				}
			}
			else
			{
				this.rbzd.Checked = true;
			}
			this.xfshuiliang.Text = userSetting.GetValue("WaterTankCalculate", "xfshuiliang");
			this.xftime.Text = userSetting.GetValue("WaterTankCalculate", "xftime");
			this.cbjzdj.SelectedIndex = int.Parse(userSetting.GetValue("WaterTankCalculate", "jiangzhudengji"));
			string value3 = userSetting.GetValue("WaterTankCalculate", "jigusuan");
			if (!(value3 == "计算"))
			{
				if (value3 == "估算")
				{
					this.radioButton2.Checked = true;
				}
			}
			else
			{
				this.radioButton1.Checked = true;
			}
			this.zdNmax.Text = userSetting.GetValue("WaterTankCalculate", "zdNmax");
			this.zdQb.Text = userSetting.GetValue("WaterTankCalculate", "zdQb");
			this.rbQb.Text = userSetting.GetValue("WaterTankCalculate", "rbQb");
			this.rbQm.Text = userSetting.GetValue("WaterTankCalculate", "rbQm");
			this.rbTb.Text = userSetting.GetValue("WaterTankCalculate", "rbTb");
			this.rbn.Text = userSetting.GetValue("WaterTankCalculate", "rbn");
			this.dzQm.Text = userSetting.GetValue("WaterTankCalculate", "dzQm");
			this.dzT.Text = userSetting.GetValue("WaterTankCalculate", "dzT");
			this.gsQb.Text = userSetting.GetValue("WaterTankCalculate", "gsQb");
			this.gsQ.Text = userSetting.GetValue("WaterTankCalculate", "gsQ");
			this.gsT.Text = userSetting.GetValue("WaterTankCalculate", "gsT");
			this.gsTb.Text = userSetting.GetValue("WaterTankCalculate", "gsTb");
		}

		private void UserSettingWrite()
		{
			try
			{
				UserSetting userSetting = new UserSetting();
				string text = "";
				if (this.rbxf.Checked)
				{
					text = "消防";
				}
				else if (this.rbsh.Checked)
				{
					text = "生活";
				}
				else if (this.rbhy.Checked)
				{
					text = "合用";
				}
				userSetting.WriteValue("WaterTankCalculate", "yongtu", text);
				string text2 = "";
				if (this.rbzd.Checked)
				{
					text2 = "水泵自动";
				}
				else if (this.rbrg.Checked)
				{
					text2 = "水泵人工";
				}
				else if (this.rbds.Checked)
				{
					text2 = "单设水箱";
				}
				userSetting.WriteValue("WaterTankCalculate", "fangshi", text2);
				userSetting.WriteValue("WaterTankCalculate", "xfshuiliang", this.xfshuiliang.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "xftime", this.xftime.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "jiangzhudengji", this.cbjzdj.SelectedIndex.ToString());
				string text3 = "";
				if (this.radioButton1.Checked)
				{
					text3 = "计算";
				}
				else if (this.radioButton2.Checked)
				{
					text3 = "估算";
				}
				userSetting.WriteValue("WaterTankCalculate", "jigusuan", text3);
				userSetting.WriteValue("WaterTankCalculate", "zdNmax", this.zdNmax.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "zdQb", this.zdQb.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "rbQb", this.rbQb.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "rbQm", this.rbQm.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "rbTb", this.rbTb.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "rbn", this.rbn.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "dzQm", this.dzQm.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "dzT", this.dzT.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "gsQb", this.gsQb.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "gsQ", this.gsQ.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "gsT", this.gsT.Text.Trim());
				userSetting.WriteValue("WaterTankCalculate", "gsTb", this.gsTb.Text.Trim());
			}
			catch (Exception)
			{
			}
		}

		private void InitDataGridViewColumn()
		{
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn.HeaderText = "容积(m3)";
			dataGridViewTextBoxColumn.Width = 90;
			dataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.Automatic;
			dataGridViewTextBoxColumn.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn2.HeaderText = "水箱长";
			dataGridViewTextBoxColumn2.Width = 80;
			dataGridViewTextBoxColumn2.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn2.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn2);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn3.HeaderText = "水箱宽";
			dataGridViewTextBoxColumn3.Width = 80;
			dataGridViewTextBoxColumn3.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn3.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn3);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn4.HeaderText = "水箱高";
			dataGridViewTextBoxColumn4.Width = 80;
			dataGridViewTextBoxColumn4.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn4.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn4);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn5 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn5.HeaderText = "重量(kg)";
			dataGridViewTextBoxColumn5.Width = 90;
			dataGridViewTextBoxColumn5.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn5.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn5);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn6 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn6.HeaderText = "名称";
			dataGridViewTextBoxColumn6.Width = 120;
			dataGridViewTextBoxColumn6.SortMode = DataGridViewColumnSortMode.Automatic;
			dataGridViewTextBoxColumn6.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn6);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn7 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn7.HeaderText = "型号";
			dataGridViewTextBoxColumn7.Width = 90;
			dataGridViewTextBoxColumn7.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn7.ReadOnly = true;
			dataGridViewTextBoxColumn7.Visible = false;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn7);
		}

		private void rdFilter_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateDataGridView();
		}

		private void GetAllWaterTankInfo()
		{
			this.listWaterTank = this.sfdr.GetAllWaterTank("WaterTank");
			this.listWaterTankPara = this.sfdr.GetWaterTankParaOfAll("WaterTankData");
		}

		private void UpdateDataGridView()
		{
			if (this.dataGridView.Rows.Count > 1)
			{
				this.dataGridView.Rows.Clear();
			}
			if (this.rdFilter.Checked)
			{
				double num = double.Parse(this.zrj.Text);
				using (List<ListItemWaterTankPara>.Enumerator enumerator = this.listWaterTankPara.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						ListItemWaterTankPara item = enumerator.Current;
						if (double.Parse(item.volume) >= num)
						{
							string name = this.listWaterTank.FirstOrDefault((ListItemWaterTank q) => q.id == item.id).name;
							object[] values = new object[]
							{
								double.Parse(item.volume),
								item.length,
								item.width,
								item.height,
								item.weight,
								name,
								item.specname
							};
							this.dataGridView.Rows.Add(values);
						}
					}
					goto IL_21C;
				}
			}
			using (List<ListItemWaterTankPara>.Enumerator enumerator = this.listWaterTankPara.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					ListItemWaterTankPara item = enumerator.Current;
					string name2 = this.listWaterTank.FirstOrDefault((ListItemWaterTank q) => q.id == item.id).name;
					object[] values2 = new object[]
					{
						double.Parse(item.volume),
						item.length,
						item.width,
						item.height,
						item.weight,
						name2,
						item.specname
					};
					this.dataGridView.Rows.Add(values2);
				}
			}
			IL_21C:
			if (this.dataGridView.Rows.Count > 0)
			{
				ListSortDirection direction = ListSortDirection.Ascending;
				this.dataGridView.Sort(this.dataGridView.Columns[0], direction);
				this.dataGridView.Rows[0].Selected = true;
			}
		}

		private void btnLay_Click(object sender, EventArgs e)
		{
			if (this.dataGridView.SelectedRows.Count > 0)
			{
				string name = this.dataGridView.SelectedRows[0].Cells[5].Value.ToString();
				string spec = this.dataGridView.SelectedRows[0].Cells[6].Value.ToString();
				FormLayWaterTankNew formLayWaterTankNew = new FormLayWaterTankNew(name, spec, this.doc);
				base.Opacity = 0.0;
				if (formLayWaterTankNew.ShowDialog() == DialogResult.OK)
				{
					this.offset = formLayWaterTankNew.offset;
					this.currentTankPara = formLayWaterTankNew.currentTankPara;
					base.DialogResult = DialogResult.OK;
					return;
				}
				base.Opacity = 1.0;
			}
		}

		private void zrj_TextChanged(object sender, EventArgs e)
		{
			if (this.zrj.Text.Trim() != "")
			{
				this.UpdateDataGridView();
			}
		}

		public double offset = 0.5;

		public Document doc;

		private SpaceFamilyDataReader sfdr = new SpaceFamilyDataReader();

		private HVACUserSetting userSetting = new HVACUserSetting();

		private List<ListItemWaterTank> listWaterTank = new List<ListItemWaterTank>();

		private List<ListItemWaterTankPara> listWaterTankPara = new List<ListItemWaterTankPara>();

		public ListItemWaterTankPara currentTankPara;
	}
}
